package com.baifendian.service.impl;

import com.baifendian.common.utils.DateUtils;
import com.baifendian.dao.entity.RcApiSysStat;
import com.baifendian.dao.entity.RcDataInterStat;
import com.baifendian.dao.mapper.RcDataInterStatMapper;
import com.baifendian.service.RcDataInterStatService;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

/**
 * @author peng.guo on 2018/3/7.
 *
 */
@Service
public class RcDataInterStatImpl implements RcDataInterStatService {
  @Resource
  private RcDataInterStatMapper rcDataInterStatMapper;

  @Override
  public List<RcDataInterStat> getRcDataInterStatByDay(Date date) {
    return rcDataInterStatMapper.getRcDataInterStatByDay(date);
  }

  @Override
  public List<RcDataInterStat> getRcDataInterStatByMonth(Date date) {
    return rcDataInterStatMapper.getRcDataInterStatByMonth(date);
  }

  @Override
  public void saveRcDataInterStat(List<RcDataInterStat> rcDataInterStatList) {

    for(RcDataInterStat rcDataInterStat : rcDataInterStatList){
      if(ObjectUtils.isEmpty(rcDataInterStat)){
        continue;
      }
      rcDataInterStat.setStatDate(DateUtils.localDateTimeToDate(DateUtils.getCurrentTime()));
      rcDataInterStatMapper.insertSelective(rcDataInterStat);
    }
  }

  @Override
  public void delRcDataInterStatByDay() {
    rcDataInterStatMapper.delRcDataInterStatByDay();
  }


  @Override
  public void delRcDataInterStatByMonth() {
    rcDataInterStatMapper.delRcDataInterStatByMonth();
  }


}
